package com.firebird.app.fejpsl.ui.activity.sword.friend;

import android.content.res.Resources;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;

import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.firebird.app.fejpsl.R;
import com.firebird.app.fejpsl.adapter.FollowAdapter;
import com.firebird.app.fejpsl.base.BaseTbActivity;
import com.firebird.app.fejpsl.mvp.model.bean.Follow;

import java.util.ArrayList;
import java.util.List;

public class FollowMeActivity extends BaseTbActivity {

    private RecyclerView recyclerView;
    private TextView tv_back;
    private List<Follow> datas;
    private FollowAdapter adapter;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.sword_friend_follow_me);

        //初始化RecyclerView
        recyclerView = (RecyclerView) findViewById(R.id.recycler_view);

        datas = new ArrayList<>();
        Follow follow;
        for (int i = 0; i < 15; i++) {
            follow = new Follow();
            follow.setUser_name("法" + i + "海");
            follow.setFollow_uuid("13432213");
            follow.setUser_uuid("382833222");
            follow.setImage_path("qc11ht07f.bkt.clouddn.com/FrgcRU5kYiWD5BlQqWMlgLuN_c6S");
            follow.setContent("测试50" + i + "|合格300");
            datas.add(follow);
        }

        Resources resources = this.getResources();
        Drawable drawable = resources.getDrawable(R.drawable.back);
        drawable.setBounds(0, 0, 120, 120);
        tv_back = (TextView) findViewById(R.id.tv_back);
        tv_back.setCompoundDrawables(drawable, null, null, null);
        setBack();
        String titleName = this.getResources().getText(R.string.follow_me).toString();
        setTitle(titleName);

        //创建布局管理
        LinearLayoutManager layoutManager = new LinearLayoutManager(this);
        layoutManager.setOrientation(LinearLayoutManager.VERTICAL);
        recyclerView.setLayoutManager(layoutManager);

        //创建适配器
        adapter = new FollowAdapter(R.layout.item_follow_list, datas);

        //条目子控件点击事件
        adapter.setOnItemChildClickListener(new BaseQuickAdapter.OnItemChildClickListener() {
            @Override
            public void onItemChildClick(BaseQuickAdapter adapter, View view, int position) {

                Toast.makeText(FollowMeActivity.this, "点击了第" + (position + 1) + "条条目的图片", Toast.LENGTH_SHORT).show();
            }
        });
        //给RecyclerView设置适配器
        recyclerView.setAdapter(adapter);

        ImageView imageView = (ImageView) findViewById(R.id.iv_avatar);

        //Glide.with(this).load("qc11ht07f.bkt.clouddn.com/FrgcRU5kYiWD5BlQqWMlgLuN_c6S").into(imageView);
    }
}
